package com.pankaj;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.ViewSwitcher;
import com.pankaj.R;

public class LazyAdapter extends BaseAdapter {
	private Activity activity;
	private String[] data, title;
	private static LayoutInflater inflater = null;
	public ImageLoaderSlide1 imageLoader;
	
	public LazyAdapter(Activity a, String[] d, String[] d1) {
		activity = a;
		data = d;
		title = d1;
		inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		imageLoader = new ImageLoaderSlide1(activity.getApplicationContext());
	}
	public int getCount() {
		return data.length;
	}
	public Object getItem(int position) {
		return position;
	}
	public long getItemId(int position) {
		return position;
	}
	public View getView(int position, View convertView, ViewGroup parent) {
		View vi = convertView;
		if (convertView == null)vi = inflater.inflate(R.layout.m_item, null);
		
		TextView mtitle = (TextView) vi.findViewById(R.id.title);
		ImageView image = (ImageView) vi.findViewById(R.id.image);
		ViewSwitcher switcher = (ViewSwitcher) vi.findViewById(R.id.viewswitcher1);
		mtitle.setText(title[position]);
		
		imageLoader.DisplayImage(data[position], image,switcher);
		return vi;
	}
}